module.exports = app => {
    const { INTEGER, STRING, DATE } = app.Sequelize;
    const lockPermission = app.model.define('lock_permission', {
        lockId: {
            type: STRING(50),
            allowNull: false,
            field: 'lock_id',
            primaryKey: true,
        },
        userId: {
            type: STRING(50),
            allowNull: false,
            field: 'user_id',
            primaryKey: true,
        },
        hotelId: {
            type: STRING(50),
            allowNull: false,
            field: 'hotel_id',
        },
        type: {
            type: STRING(30),
            allowNull: false,
            field: 'type',
        },
        startTime: {
            type: DATE,
            allowNull: true,
            field: 'start_time',
        },
        endTime: {
            type: DATE,
            allowNull: true,
            field: 'end_time',
        },
    }, {
        timestamps: true,
        paranoid: false,
        underscored: true,
        freezeTableName: true,
        getterMethods: {
            created_at() {
                return this.getDataValue('created_at') && this.getDataValue('created_at').toLocaleString();
            },
            updated_at() {
                return this.getDataValue('updated_at') && this.getDataValue('updated_at').toLocaleString();
            }
        },
    });

    return lockPermission;
}